package com.zrrd.learn.chapter06数组;

import java.util.Arrays;

/**
 * 线性结构
 *
 * @author wrn
 * @version 1.0
 * @date 2023/7/14 10:49
 */

public class LinearStructureLianxi {

    /**
     * 现有一个数组{1,2,3,4,1,1,2,3,4,4,5,5,6,7} ,
     * 请将数组数组里面的重复项去掉，把内容存储到自定的变长数组里。
     */
    public static void repeat(){

        int init_capacity = 0;
        int max_capacity = Integer.MAX_VALUE;
        int[] bottom_array;
        int index = 0;
        bottom_array = new int[init_capacity];


        int[] array = {1,2,3,4,1,1,2,3,4,4,5,5,6,7};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));

        for (int i = 0; i < array.length; i++) {
            int num = 0;
            for (int j = i; j < array.length; j++) {
                if (array[j] > 0) {
                    if (array[i] != array[j]) {
                        num = j;
                        break;
                    }
                }
            }
            System.out.print(array[i]);
            i = (num == 0) ? array.length - 1 : num - 1;

        }



    }

    public static void main(String[] args) {
        repeat();
    }
}
